home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
F1 Licenseware
/
F1 Licenseware - Volume 1.iso
/
disks
/
089a.dms
/
089a.adf
/
EXAMPLE_PROGRAMS
/
example23.AMOS
/
example23.amosSourceCode
Wrap
AMOS Source Code
|
1992-03-06
|
4KB
|
101 lines
'==============
'Example23.Amos
'==============
Rem Guess the hidden word game.
Rem This is nowhere near a complete game, it's purpose it soley to demonstrate
Rem the use of the INSTR command explained fully in chapter 23.
Rem The major deficencies are that you cannot use words with more than 1
Rem identical letter, no scoring or limits to key presses it dosent check
Rem if the same word is going to be used more than once etc.
Rem Why not see if you can add these features and more?
'------------------------------------------------------------------------------
Curs Off : Hide : Paper 0
Rem DIMension an array called A$ to store some words in
Rem you can expand this easily simply by changing the 14, adding more
Rem text inside the data statements and the 14 in the for next loop.
'----------------------------------------------------------------------
Dim A$(14)
For A=1 To 14 : Read A$(A) : Next A
Data "WARM","AMOS","RELATION","TUNIC","FATHER","BOLD","CRISPY"
Data "QUICKEN","EXTRA","FINAL","DOPEY","WOVEN","HOME","STADIUM"
BEGIN:
Rem STORE$ will hold the previous guesses of the player
Rem FOUND will be incremented each time a letter is found by player
Rem when FOUND=the same length as the chossen word the word must of been found.
'------------------------------------------------------------------------------
Cls 0
STORE$=""
FOUND=0
Rem Pick on of the words from the data at random.
Rem L will tell us the length of the chossen word for use later
'---------------------------------------------------------------
WORD=Rnd(13)+1
L=Len(A$(WORD))
Rem Print the same amount of dashes as letters in the word to give player
Rem a clue.
'-------------------------------------------------------------------------
Pen 4 : Locate 0,3 : Print String$("-",L)
Home : Pen 5
Under On : Centre "GUESS THE HIDDEN WORD" : Under Off
Rem If you want to cheat unrem this line
'----------------------------------------
'locate 0,1:Print A$(WORD)
Rem Start of the main loop
'-------------------------
Do
Rem wait for a key press. Turn the keypress in to an upper case character.
'------------------------------------------------------------------------
GKEY:
K$="" : While K$="" : K$=Inkey$ : Wend
K$=Upper$(K$)
Rem check to see if key has already been used. If yes then goto keypress again
'--------------------------------------------------------------------------------
X=Instr(STORE$,K$)
If X<>0 Then Goto GKEY
Rem Now see if the selected letter is actually in the hidden word.
Rem If X is not zero then we have a match
Rem if a match is found print that letter on the correct - mark.
Rem As we are using IF ENDIF this part will be skip if the IF is false.
'------------------------------------------------------------------
X=Instr(A$(WORD),K$)
If X<>0
Pen 6 : Locate X-1,3 : Print K$
Inc FOUND
End If
Rem Remember the key pressed by adding it to thestring Store$
Rem and print store$ on screen so user can see.
'-------------------------------------------------------------
STORE$=STORE$+K$+","
Pen 2 : Locate 0,20 : Print STORE$
Rem Another Endif jobbie, checks to see if the player has FOUUND all the
Rem letters in the word, if not the program jumps back to the beginning
Rem of the Do Loop. If sucess then print a message,wait for a key press
Rem then go back to begin and start a new game.
'-----------------------------------------------------------------------
'
If FOUND=L
Pen 3
Locate 0,10 : Centre "WELL DONE, PRESS A KEY"
Clear Key
Wait Key
Goto BEGIN
End If
Loop